package com.blockmeta.bbs.businesslibrary.launch;

import com.blockmeta.bbs.baselibrary.base.app.BaseApp;
import com.blockmeta.bbs.baselibrary.utils.SharedPreferenceUtil;
import com.blockmeta.bbs.baselibrary.utils.gson.GsonUtil;
import com.blockmeta.bbs.businesslibrary.pojo.QuHuiConfigPOJO;

import java.util.HashMap;
import java.util.Map;

public class QuHuiConfigYMAL implements IBaseYMAL {
    public static final String QU_HUI_CONFIG = "QuHuiConfig";
    public static QuHuiConfigPOJO quHuiConfigPOJO;
    @Override
    public Map<String, Object> parser(String content, String env) {
        try {
            quHuiConfigPOJO = GsonUtil.buildGson().fromJson(content, QuHuiConfigPOJO.class);
            SharedPreferenceUtil.putString(BaseApp.getApp(), QU_HUI_CONFIG, content);
        } catch (Exception e) {
        }
        return new HashMap<String, Object>();
    }

    public static QuHuiConfigPOJO getQuHuiConfigPOJO(){
        if(quHuiConfigPOJO != null){
            return quHuiConfigPOJO;
        }else {
            synchronized (QuHuiConfigYMAL.class) {
                if(quHuiConfigPOJO == null) {
                    String navigationYMAL = SharedPreferenceUtil.getString(BaseApp.getApp(), QU_HUI_CONFIG, "");
                    quHuiConfigPOJO = GsonUtil.buildGson().fromJson(navigationYMAL, QuHuiConfigPOJO.class);
                    return quHuiConfigPOJO;
                }
            }
        }
        return quHuiConfigPOJO;
    }
}
